package com.example.leetcode.tree;

import com.example.leetcode.tree.common.TreeNode;
import com.example.leetcode.tree.common.TreeUtils;

/**
 * Definition for a binary tree node.
 * public class TreeNode {
 * int val;
 * TreeNode left;
 * TreeNode right;
 * TreeNode() {}
 * TreeNode(int val) { this.val = val; }
 * TreeNode(int val, TreeNode left, TreeNode right) {
 * this.val = val;
 * this.left = left;
 * this.right = right;
 * }
 * }
 */
class Solution1026 {
    public int maxAncestorDiff(TreeNode root) {
        return TreeUtils.maxAncestorDiff(root);
//        return TreeUtils.maxAncestorDiff2(root);
    }
}

public class leetcode1026 {
    public static void main(String[] args) {
        Solution1026 solution1026 = new Solution1026();
        Integer[] root = {8, 3, 10, 1, 6, null, 14, null, null, 4, 7, 13};
        Integer[] root1 = {2, null, 0, null, 4, null, 3, null, 1};
        System.out.println(solution1026.maxAncestorDiff(TreeUtils.generateLeetcodeTree(root)));
        System.out.println(solution1026.maxAncestorDiff(TreeUtils.generateLeetcodeTree(root1)));
    }
}
